package com.fattyCorps.account.uitl;

import com.fattyCorps.account.exception.TokenErrorException;
import com.fattyCorps.account.service.LoginService;
import com.fattyCorps.common.util.JwtUtils;

import javax.servlet.http.HttpServletRequest;

public class AccJwtUtils {

    public static final String ACC_ID_NAME = "id";

    public static Integer getAccIdByRequest(HttpServletRequest request){
        Integer id = JwtUtils.getIdByRequest(request, ACC_ID_NAME, LoginService.JWT_SECRET);
        if (id == 0) {
            throw new TokenErrorException();
        }

        return id;
    }
}
